package com.example.service;




import com.example.dao.MemberDao;
import com.example.domain.pojo.Member;
import com.example.domain.utils.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MemberService  {
    @Autowired
    private MemberDao memberDao;


    //根据电话查询是否是会员  //
    public Member findTelement(String telephone) {
        Member findmember = memberDao.findmember(telephone);
        return findmember;
    }

    //保存会员信息,注册会员
   public void add(Member member) {
        //判断密码是否为空,表单提交调用,将密码转为加密的密码
        String password = member.getPassword();
        //用户注册,对密码进行加密
        if(password!=null){
            //用户提交设置密码,使用MD5,加密
            password= MD5Utils.md5(password);
            member.setPassword(password);
        }
        memberDao.addmember(member);
    }


    //实名认证,修改会员信息
    public Member updateMember(Member member) {
        memberDao.updateMember(member);
        Member member1 = memberDao.findmemberById(member.getId());
        return member1;
    }

    public void updatePassword(Member member) {
        memberDao.updateMember(member);
    }
}
